import React from 'react';
import ReactDOM from 'react-dom';
import { HotTable } from '@handsontable/react';
import Handsontable from 'handsontable';
import 'handsontable/dist/handsontable.full.css';

// import { jsPDF } from "jspdf";
// const doc = new jsPDF();
// doc.text("Hello world!", 10, 10);
// setTimeout(() => {
//   // doc.save("a4.pdf");
// }, 2333);
import { exportPDF } from '../common';
export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.handsontableData = Handsontable.helper.createSpreadsheetData(666, 10);
    this.hot = React.createRef()
  }
  componentDidMount () {
    // let hotInstance = this.hot.current.hotInstance
    // hotInstance.view.wt.update('onCellDblClick', function (row,cell) { 
    //     //Get editor and begin edit mode on current cell (maintain current double click functionality) 
    //     var activeEditor = hotInstance.getActiveEditor(); 
    //     activeEditor.beginEditing(); 
    
    //     //Do whatever you want... 
    //     console.log('dbclick','AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')
    // }); 
  }
  render() {
    return (
      <div id='container'>
        <button onClick={() => {
          let dom = document.getElementById('container')
          exportPDF('container', dom)
        }}>导出PDF</button>
        <HotTable
          id="hot"
          ref={this.hot}
          data={this.handsontableData}
          colHeaders={true}
          rowHeaders={true}
          fillHandle ={true}
          fixedRowsTop ={4}
          fixedColumnsLeft ={4}          
          // manualRowResize={true}
          />
      </div>
    );
  }
}

